
const { program } = require('commander');

const check = (value) => {
  // var arr = value.split();
  // console.log('value===' + value);
  // const array = value.concat([parseInt(value, 10)]);
 
  // var array = [];
  // const result = array.push(arr);
  // console.log('result:' + array);
  // for (var index in value) {
  //   console.log('values:' + value[index])
  // }
  // console.log('arr:' + arr);
  // console.log('value:' + value);
  // var arr = []
  // const array = arr.concat(parseInt(value, 10));
  // const str = JSON.stringify(array);
  // console.log('array:' + str);
  // const array = JSON.stringify(value);
  // var arr = [];
  // var string = arr.concat(array);
  // console.log('==' + string);
  // console.log('arr:' + array);
  
  var arr = [];
  const array = arr.concat(parseInt(value, 10));
  console.log('array:' + array);
  return array;
}

function collect(value, previous) {
  return previous.concat([value]);
}

program
  .argument('<numbers>', 'this is a number')
  .option('-t, --times <times...>', 'this is a number', collect,[])
  .action(async (numbers, options) => {
    await main(numbers, options.times);
  })
  .argument('<num>', 'this is a work');

  program.parseAsync(process.argv)
  .then(() => {
    console.log('DONE');
    process.exit(0);
  })
  .catch((err) => {
    console.error(err);
    process.exit(1);
  });

async function main(numbers,times) {
  console.log('numbers=' + numbers);
  console.log('array=' + times);
  const time = times[0];
  console.log('time=' + time);
}